import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    component: () => import('../views/index.vue'),
  },
  {
    path: '/miner',
    component: () => import('../views/miner.vue'),
  },
  {
    path: '/login',
    component: () => import('../views/login.vue'),
  },
  {
    path: '/register',
    component: () => import('../views/register.vue'),
  },
]

const router = createRouter({
  routes,
  history: createWebHashHistory(),
  scrollBehavior(to, from, savedPosition) {
    if (to.hash) {
      return {
        el: to.hash,
      }
    } else if (savedPosition) {
      return savedPosition
    } else {
      return { top: 0 }
    }
  },
})

export default router
